import { arrayGroup } from "@/utils/smallTool";

const statusConfig = {
    '0': '维护中',
    '1': '已开通',
    '2': '未开通'
};
const statisticsArr = {
    '1': '全部数据',
    '2': '近一年数据',
    '3': '近三年数据',
}
const calculatorConfig = {
    '0': '不支持',
    '1': '官网获取',
    '2': '公式计算'
};
const supportConfig = {
    '0': '不支持',
    '1': '支持'
};
const staticsticsConfig = {
    '0': '按年统计',
    '1': '次统计'
};
const suportConfig = {
    '0': '不支持',
    '1': '官网链接',
    '2': '查悦链接'
}
const showModeConfig = {
    '0': '官网显示',
    '1': '查悦显示'
}
const showSwitchConfig = {
    '0': '显示',
    '1': '不显示'
}
const insuranceList = [
    { name: '不支持', value: '00:不支持' },
    { name: '养老', value: '01:养老' },
    { name: '失业', value: '02:失业' },
    { name: '医疗', value: '03:医疗' },
    { name: '工伤', value: '04:工伤' },
    { name: '生育', value: '05:生育' },
    { name: '大病险', value: '06:大病险' },
    { name: '基础五险', value: '07:基础五险' },
    { name: '六险', value: '08:六险' },
];
const transArrByObj = (obj) => {
    return Object.keys(obj).map((key) => {
        return {
            name: obj[key],
            value: key
        }
    })
}
const getFundSearchInputConfig = (cityList) => [
    {
        type: 'select',
        placeholder: '请选择',
        name: 'cityCode',
        label: '城市',
        nameFiled: 'cityName',
        valueFiled: 'cityCode',
        optionData: cityList,
    },
    {
        type: 'select',
        placeholder: '请选择',
        optionData: [{ value: '0', name: '维护中' }, { value: '1', name: '已开通' }, { value: '2', name: '未开通' }],
        name: 'status',
        label: '城市状态',
        selectProps: {
            allowClear: true,
        }
    },
    {
        type: 'select',
        placeholder: '请选择',
        optionData: transArrByObj(suportConfig),
        name: 'activationRegisteredLink',
        label: '激活注册',
        selectProps: {
            allowClear: true,
        }
    },
    {
        type: 'select',
        placeholder: '请选择',
        optionData: transArrByObj(suportConfig),
        name: 'forgetPasswordLink',
        label: '忘记密码',
        selectProps: {
            allowClear: true,
        }
    },
    {
        type: 'select',
        placeholder: '请选择',
        optionData: transArrByObj(showSwitchConfig),
        name: 'userNameStatus',
        label: '显示姓名',
        selectProps: {
            allowClear: true,
        }
    },
    {
        type: 'select',
        placeholder: '请选择',
        optionData: transArrByObj(supportConfig),
        name: 'remittanceDetails',
        label: '汇缴明细（是否支持）',
        selectProps: {
            allowClear: true,
        }
    },
    {
        type: 'select',
        placeholder: '请选择',
        optionData: transArrByObj(showModeConfig),
        name: 'remittanceBalance',
        label: '汇缴明细（余额显示）',
        selectProps: {
            allowClear: true,
        }
    },
    {
        type: 'select',
        placeholder: '请选择',
        optionData: transArrByObj(statisticsArr),
        name: 'remittanceData',
        label: '汇缴明细（统计数据）',
        selectProps: {
            allowClear: true,
        }
    }
];
const getEditInputConfig = (record) => {
    return [
        {
            type: 'input',
            placeholder: '请选择',
            name: 'cityCode',
            hidden: true,
            initialValue: record.cityCode,
            label: '城市',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'cityName',
            initialValue: record.cityName,
            label: '城市',
            required: true,
            nameFiled: 'cityName',
            valueFiled: 'cityCode',
            disabled: record.cityName ? true : false,
            optionList: {
                list: record.cityList
            }
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'status',
            decorator: true,
            initialValue: record.status || '0',
            optionList: {
                list: transArrByObj(statusConfig)
            },
            label: '城市状态',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'activationRegisteredLink',
            initialValue: record.activationRegisteredLink || '0',
            decorator: true,
            optionList: {
                list: transArrByObj(suportConfig)
            },
            label: '激活注册',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'forgetPasswordLink',
            decorator: true,
            initialValue: record.forgetPasswordLink || '0',
            optionList: {
                list: transArrByObj(suportConfig)
            },
            label: '忘记密码',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'medicalDebit',
            decorator: true,
            initialValue: record.medicalDebit || '0',
            optionList: {
                list: transArrByObj(calculatorConfig)
            },
            label: '公积金账户',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'userNameStatus',
            decorator: true,
            initialValue: record.userName || '0',
            optionList: {
                list: transArrByObj(showSwitchConfig)
            },
            label: '姓名展示',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'medicalExpenditure',
            decorator: true,
            initialValue: record.statisticsType || '0',
            optionList: {
                list: transArrByObj(supportConfig)
            },
            label: '汇缴明细',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'statisticsType',
            decorator: true,
            initialValue: record.statisticsType || '0',
            optionList: {
                list: transArrByObj(showModeConfig)
            },
            label: '汇缴明细（显示余额）',
        },
        {
            type: 'select',
            placeholder: '请选择',
            name: 'statisticsData',
            decorator: true,
            initialValue: String(record.statisticsData || '1'),
            optionList: {
                list: transArrByObj(statisticsArr)
            },
            label: '汇缴明细（统计数据）',
        },
    ]
};
const getTableConfig = (OptionNode) => {
    return [
        {
            title: '城市编码',
            dataIndex: 'cityCode',
        },
        {
            title: '城市名称',
            dataIndex: 'cityName',
        },
        {
            title: '状态',
            dataIndex: 'status',
            render: (text) => (statusConfig[text])
        },
        {
            title: '激活注册',
            dataIndex: 'activationRegisteredLink',
            width: '10%',
            render: (text) => (suportConfig[text])
        },
        {
            title: '忘记密码',
            dataIndex: 'forgetPasswordLink',
            render: (text) => (suportConfig[text])
        },
        {
            title: '公积金帐户',
            dataIndex: 'medicalDebit',
            render: (text) => (calculatorConfig[text])
        },
        {
            title: '姓名显示情况',
            dataIndex: 'userName',
            render: (text) => (showSwitchConfig[text])
        },
        {
            title: '汇缴明细',
            dataIndex: 'shebao',
            children: [
                {
                    title: '是否支持',
                    dataIndex: 'medicalExpenditure',
                    render: (text) => (supportConfig[text])
                },
                {
                    title: '统计数据',
                    dataIndex: 'statisticsData',
                    render: (text) => (staticsticsConfig[text])
                },
                {
                    title: '余额显示',
                    dataIndex: 'statisticsType',
                    render: (text) => (showModeConfig[text])
                },
            ],
        },
        {
            title: '操作',
            dataIndex: 'note',
            render: (text, record) => <OptionNode record={record}></OptionNode>
        },
    ];
}
export default {
    getEditInputConfig,
    getFundSearchInputConfig,
    getTableConfig
}